//package pers.mobian.aop;
//
//import org.aopalliance.intercept.MethodInterceptor;
//import org.aopalliance.intercept.MethodInvocation;
//import org.springframework.aop.framework.ProxyFactory;
//
///**
// * @Date 2021/10/8 21:04
// * @Created mobian
// * @Description
// */
//public class ProxyFactoryTest3 {
//	public static void main(String[] args) {
//
//		UserService service = new UserServiceImpl();
//
//		ProxyFactory factory = new ProxyFactory();
//		// 设置了接口，就会使用jdk的动态代理
//		factory.setInterfaces();
//		factory.setTarget(service);
//		factory.addAdvice(new MoBeforeAdvice());
//		factory.addAdvice(new MoAfterAdvice());
//		factory.addAdvice(new MoThrowsAdvice());
//		factory.addAdvice(new MethodInterceptor() {
//			@Override
//			// 此处的MethodInvocation是aop包下的,和使用cglib动态代理的MethodInvocation类的来源不一样
//			public Object invoke(MethodInvocation invocation) throws Throwable {
//				System.out.println("90809");
//				Object proceed = invocation.proceed();
//				throw new NullPointerException("xx");
////				System.out.println("3333");
////				return proceed;
//			}
//		});
////		factory.addAdvisor(new PointcutAdvisor() {
////			@Override
////			public Pointcut getPointcut() {
//////				return new StaticMethodMatcherPointcut() {
//////					@Override
//////					public boolean matches(Method method, Class<?> targetClass) {
//////						// 用于匹配类名
//////						return false;
//////					}
//////				};
////				new Pointcut() {
////					@Override
////					public ClassFilter getClassFilter() {
////						return null;
////					}
////
////					@Override
////					public MethodMatcher getMethodMatcher() {
////						return new MethodMatcher() {
////							@Override
////							public boolean matches(Method method, Class<?> targetClass) {
////								// 用来匹配方法的名字
////								return false;
////							}
////
////							@Override
////							public boolean isRuntime() {
////								// 设置为true，即可获得方法的参数，然后添加到对应的list集合中
////								return false;
////							}
////
////							@Override
////							public boolean matches(Method method, Class<?> targetClass, Object... args) {
////								// 前面的isRunTime为true，才会执行这一步
////								// 真正在调用执行链list的时候，会去判断，如果参数匹配，才会真正的去执行，这里可以用来添加逻辑
////								return false;
////							}
////						};
////					}
////
////				};
////				return null;
////
////			}
////
////			@Override
////			public Advice getAdvice() {
////				return null;
////			}
////
////			@Override
////			public boolean isPerInstance() {
////				return false;
////			}
////		});
//
//		UserService proxy = (UserService) factory.getProxy();
//		proxy.show();
//	}
//}
